
#ifndef INCLUDE_LOOP
#define INCLUDE_LOOP

#include <map>
#include <memory>
#include <thread>
#include <vector>

class ChannelProtocol;
class IoReuseModule;
class IoReuseModuleFactory;
class Loop
{
public:
    Loop();
    ~Loop();
    explicit Loop(IoReuseModuleFactory * factory);
    void Run();
public:
    bool AddEvent(const std::shared_ptr<ChannelProtocol>& channel, int event);
    bool ModEvent(int64_t, int  event) const;
    bool DelEvent(int64_t);
    bool AddPostTask(const std::shared_ptr<ChannelProtocol> &channel);
private:
    bool m_status{};
    std::thread::id                m_thread_id;
    std::shared_ptr<IoReuseModule> m_ioreuse_module;
private:
    std::map<int64_t, std::shared_ptr<ChannelProtocol>> m_channel_protocol_map;
    std::vector<std::shared_ptr<ChannelProtocol>>       m_channel_post_task;
};

#endif
